from mysql.connector import IntegrityError

from utils.sql_utils.set import cursor, database


def update_user_form(student_num: int, username: str, sex: str, connect: str, desc: str) -> str:

    try:
        cursor.execute(f'insert into we_data (sn, un, sex, conn, `desc`)'
                       f' values({student_num}, "{username}", "{sex}", "{connect}", "{desc}")')
        database.commit()
    except IntegrityError:
        return '4'
    except Exception as e:
        print(e)
        return '3'

    return '1'


if __name__ == '__main__':
    print(update_user_form(1234, 'aaa', '男', 'aaaaaa@gamil.com', '这是一条简介'))
